import translations from './translations'

export default function customTranslate(template, replacements) {
  // 确保 template 是字符串
  const stringTemplate = typeof template === 'string' ? template : String(template || '')

  // 查找中文翻译
  const translation = translations[stringTemplate] || stringTemplate

  // 如果有替换变量
  if (replacements) {
    return translation.replace(/{([^}]+)}/g, function (_, key) {
      return replacements[key] || '{' + key + '}'
    })
  }

  return translation
}
